# 安装

  1. 在目录/opt/primeton/APIGateway创建“Primeton_APIGateway_9.0_LA_Governor_Standalone”目录。
  2. 解压安装包Primeton_APIGateway_9.0_LA_Governor_Standalone.tar到 “Primeton_APIGateway_9.0_LA_Governor_Standalone”目录中。
> tar -xvf Primeton_APIGateway_9.0_LA_Governor_Standalone.tar -C Primeton_APIGateway_9.0_LA_Governor_Standalone

# 初始化数据库

  1. 以 Mysql 为例,创建编码格式为 UTF-8 的数据库 APIGateway。
  2. 在“${APIGateway-governor安装目录}/db-scripts”目录下,按照数字顺序执行数据库脚本,具体顺序如下:
1. eos/Mysql/eos_all.sql
2. afcenter/Mysql/afc_all.sql
3. esb/Mysql/1-esb-afc-data.sql
4. esb/Mysql/2-schema-esb-mysql.sql
5. esb/Mysql/3-data-esb-mysql.sql

# 配置

  1. 将数据库驱动包拷贝到“${APIGateway-governor安装目录}/lib”目录下。

    说明:

    1).查看1.1 安装须知 ,检查您所需要的数据库驱动包是否已被内置在产品中。如下图 如果没有内置,则需要删除对应数据库已内置的数据库驱动包版本,放入自己所需要的数据库驱动包 例如:您需要连接的数据库是Mysql 8,但是产品已内置的是Mysql 5的驱动包。您需要将Mysql 8的驱动包拷贝到${APIGateway-governor安装目录}/lib下,然后手动删除${APIGateway-governor安装目录}/lib目录下已内置的Mysql 5的驱动包。

  2. 打开${APIGateway-governor安装目录}\config\application.properties 修改端口、redis、jpa等配置:

server.port=8080
server.connection-timeout=60000
spring.pid.file=pid
spring.profiles.active=nacos,afc,esb
spring.application.name=esb
spring.jmx.default-domain=${spring.application.name}
spring.cloud.inetutils.preferred-networks=192.168

server.app-server.min-spare-threads=100
server.app-server.max-threads=500
server.app-server.max-connections=1000
server.app-server.accept-count=200
management.health.elasticsearch.enabled=false

spring.resources.static-locations=file:./webapp
management.endpoints.web.exposure.include=hystrix.stream,health,info,loggers,eos,mappings
spring.main.allow-bean-definition-overriding=true  

out.config.folder=config
eos.profiles.active=dev
eos.cache.mode=redis
eos.admin.port=${server.port}
eos.application.sys-code=EOS-DEMO-SYS
eos.application.sys-key=dc6baaed30e541d78bb91274803d9432
spring.session.store-type=none

# redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
spring.redis.lettuce.pool.max-active=100
spring.redis.lettuce.pool.max-idle=100
spring.redis.lettuce.pool.max-wait=5000

# hibernate
spring.jpa.open-in-view=false
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.connection.handling_mode=IMMEDIATE_ACQUISITION_AND_HOLD
spring.jpa.properties.hibernate.new_generator_mappings=false
spring.jpa.properties.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect      #默认mysql数据库方言,其他数据库参考05.2 数据库配置
spring.jpa.properties.database=MYSQL     #默认mysql数据库,其他数据库参考05.2 数据库配置

spring.mvc.dateFormat=yyyy-MM-dd HH:mm:ss
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.serialization.write-dates-as-timestamps=false

#swagger
swagger.enable=false

# feign
feign.client.config.default.connectTimeout=2000
feign.client.config.default.readTimeout=1000

#AFC\u90E8\u7F72\u65B9\u5F0F sdk || starter
console.deploy.type=starter

#mock\u7AEF\u53E3
afc.console.mock.port=1080
参数 说明
server.port APIGateway-governor服务的端口,默认8080。
eos.cache.mode 缓存方式,默认为redis。
spring.redis.host eos.cache.mode=redis时,需要配置redis的IP地址。
spring.redis.port eos.cache.mode=redis时,需要配置redis端口。
spring.redis.password eos.cache.mode=redis时,需要配置redis密码。
spring.jpa.properties.hibernate.dialect 数据库方言类,默认mysql数据库方言,其他数据库参考高级配置。
spring.jpa.properties.database 数据库类型,默认mysql数据库类型。
  1. 打开${APIGateway-governor安装目录}\config\application-esb.properties 修改APIGateway、elasticsearch相关配置:
#esb restTemplate
esb.business=true
esb.database.init=false
esb.database.enforceInit=false
esb.rest.client.socket.timeout=20000
esb.rest.client.connect.timeout=10000
esb.rest.client.connectionRequest.timeout=10000
esb.rest.client.evictIdleConnections=60
esb.rest.client.ConnectionTimeToLive=60

elasticsearch.enabled=true
elasticsearch.ioThreadCount=50
elasticsearch.connectTimeout=60000
elasticsearch.maxTotal=10000
elasticsearch.maxPerRoute=1000
elasticsearch.numberOfShards=1
elasticsearch.numberOfReplicas=0
elasticsearch.refreshInterval=10s
elasticsearch.username=elastic
elasticsearch.password=primeton000000
elasticsearch.certificate=/usr/local/elasticsearch/elasticsearch-8.1.2/config/certs/http_ca.crt
elasticsearch.hosts[0].ip=127.0.0.1
elasticsearch.hosts[0].port=9200
elasticsearch.hosts[0].protocol=https
参数 说明
elasticsearch.enabled 是否启用ElasticSearch,默认为true。
elasticsearch.username ElasticSearch 的访问用户名,默认为elastic。
elasticsearch.password ElasticSearch 的访问密码,密码为安装elasticsearch时设置的密码
elasticsearch.certificate ElasticSearch的证书,该证书为elasticsearch-8.1.2/config/certs下的http_ca.crt文件,文件位置需配置绝对路径
elasticsearch.hosts[0].ip 配置成安装ElasticSearch的机器IP地址。
elasticsearch.hosts[0].port ElasticSearch 的启动端口号。默认为9200。
elasticsearch.hosts[0].protocol ElasticSearch 的http协议,默认https。
  1. 打开“${APIGateway-governor安装目录}/config/ESB/config/user-config.xml”文件,修改数据库及配置。
......
<group name="default">
            <configValue key="Database-Type">MySql</configValue>
            <configValue key="Jdbc-Type"/>
            <configValue key="C3p0-DriverClass">com.mysql.jdbc.Driver</configValue>
            <configValue key="C3p0-Url">jdbc:mysql://127.0.0.1:3306/APIGateway?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false</configValue>
            <configValue key="C3p0-UserName">root</configValue>
            <configValue key="C3p0-Password">root</configValue>
            <configValue key="C3p0-PoolSize">10</configValue>
            <configValue key="C3p0-MaxPoolSize">50</configValue>
            <configValue key="C3p0-MinPoolSize">10</configValue>
            <!-- //seconds, 0 means connections never expire -->
            <configValue key="C3p0-MaxIdleTime">600</configValue>
            <!-- //idle connections never tested -->
            <configValue key="C3p0-IdleConnectionTestPeriod">900</configValue>
            <configValue key="C3p0-MaxStatements">0</configValue>
            <configValue key="C3p0-NumHelperThreads">1</configValue>

            <configValue key="Transaction-Isolation">ISOLATION_DEFAULT</configValue>
            <configValue key="Test-Connect-Sql">SELECT count(*) from EOS_UNIQUE_TABLE</configValue>
            <configValue key="Retry-Connect-Count">-1</configValue>
        </group>
......
参数 说明
Database-Type host头白名单(配置服务器实际ip),用来防止host头请求攻击
DriverClass 数据库类型,根据实际环境修改。
Url 访问数据库的JDBC URL,根据实际环境修改。
UserName 数据库用户名,根据实际环境修改。例如:root
Password 数据库用户密码,根据实际环境修改。例如:111111
  1. 如果要使用sap服务器,需要将sapjco.zip (opens new window) 中对应操作系统下的libsapjco3.so和sapjco3.jar文件复制到“${APIGateway-governor安装目录}/lib”目录下

# 验证

  1. 在${APIGateway-governor安装目录}下执行以下命令,启动APIGateway Governor。
# nohup  ./startServer.sh &
  1. 启动成功后,进入${APIGateway-governor安装目录}/logs,打开eos-trace.log文件 查看具体日志,如下图所示
  2. 启动完成后以管理员身份(manager/000000)登录APIGateway Governor, 在浏览器地址栏输入http://ip:8080”(ip地址为安装APIGateway Governor的服务器地址)进入如下界面,表示APIGateway Governor系统部署成功。
说明

此版本支持三员管理,三员管理分为系统管理员、安全管理员、安全审计员

系统管理员负责创建用户、删除用户,系统管理员用户名:systemadmin,初始密码:000000

安全管理员负责给用户分配角色,角色权限设置,安全管理员用户名:security,初始密码:000000

安全审计员负责查看Governor操作日志,安全审计员用户名:audit,初始密码:000000

备注:

1.如果连续 5 次输入错误密码,则用户会被锁定 30 分钟

2.新创建的用户,首次登录后需重新修改密码,默认用户首次登录不需要修改密码,如果需要修改密码,请使用systemadmin用户在账号管理页面,重新设置默认用户的密码

4. 登录成功后,进入企业API网关页面

# 卸载

  1. 在${APIGateway-governor安装目录}下,停止APIGateway Governor服务。
> ./stopServer.sh
  1. 停止服务后,直接删除${APIGateway-governor安装目录}进行卸载。